home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- # $Header: /home/jerry/.bin/RCS/bipp,v 1.4 92/10/23 10:41:28 jerry Exp $
- ### bipp - backquote interpolating prompter preprocessor :-)
- ### Usage (in MH profile): comp: -editor bipp (etc., or Editor: bipp)
- ## Reads a "components" file, runs commands between backquotes (in header only!)
- ## starts "prompter" on the edited file. Sort of a hack, but it's a good start.
- #
- # Placed in the public domain by Jerry Peek, jerry@ora.com, 23 October 1992.
- # Use this at your own risk, inspect and fix before you use it, etc.
- # If this doesn't work the way you expect it to, that's your responsibility!
-
- stat=1 # DEFAULT EXIT STATUS (RESET TO 0 FOR NORMAL EXIT)
- temp=/tmp/EDIT$$
- trap 'rm -f $temp; exit $stat' 0 1 2 15
-
- nawk '
- BEGIN {
- inheader = 1
- }
- inheader == 1 {
- if ($0 ~ /^-*$/) {
- # END OF HEADER
- inheader = 0
- }
- else if (match($0, /`.*`/)) {
- # GET STRING, WITHOUT THE BACKQUOTES:
- torun = substr($0, RSTART + 1, RLENGTH - 2)
- # QUICK-AND-DIRTY: GET ONE LINE OF OUTPUT FROM torun:
- torun | getline tosub
- if (sub(/`.*`/, tosub) != 1) {
- printf "**** ERROR RUNNING `%s` ***\n", torun
- next
- }
- }
- }
- {
- print
- }' $1 > $temp
- # REPLACE DRAFT WITH EDITED VERSION; START prompter IF cp WORKED:
- if cp $temp $1
- then
- prompter $1
- stat=$? # EXIT WITH STATUS FROM prompter
- fi
-